﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using SBACN.WebSite.Models;
using SBACN.WebSite.Code;

namespace SBACN.WebSite.Admin.GuildMsg
{
    public partial class MonthlyEvenList : AdminBasePage
    {
		/// <summary>
		/// 系统字典类型
		/// </summary>
		public string SystemType
		{
			get
			{
				//if (ViewState["SystemType"] == null)
				//    return "00020003";//默认值
				//else
				//    return ViewState["SystemType"].ToString();
				return this.SystemCode;
			}
			private set
			{
				ViewState["SystemType"] = this.SystemCode;
			}
		}

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData(1);
            }
        }

        protected void BindData(int pageIndex)
        {
            Expression<Func<TB_MonthlyEvents, bool>> f = (p =>true);
            Expression<Func<TB_MonthlyEvents, DateTime>> o = (p => p.EventDate);
            int records = 0;
            var EventList = DAL.DALHelper.Instance.GetList<TB_MonthlyEvents, DateTime>(f, o, false, this.Pager1.PageSize, pageIndex, out records);
            this.MEList.DataSource = EventList;
            this.MEList.DataBind();
            this.Pager1.RecordCount = records;
            this.Pager1.InitControl();
        }

        public void BindSelectedPageIndexChanged(int pageIndex, int nextPage)
        {
            BindData(nextPage);
        }

        protected void btn_Delete_Click(object sender, EventArgs e)
        {
            int newsID = 0;
            if (!string.IsNullOrWhiteSpace(this.hid_ID.Value) && int.TryParse(this.hid_ID.Value, out newsID))
            {
                DAL.DALHelper.Instance.DeleteWithTransaction<TB_MonthlyEvents>("ID", newsID);
                BindData(1);
            }
            this.hid_ID.Value = string.Empty;
        }

		protected void btn_NewsRefresh_Click(object sender, EventArgs e)
		{
			BindData(this.Pager1.CurrentPageIndex);
		}
    }
}